import {sendGet, sendPost} from "@/utils/request.tsx";

/**
 * @author 橘柚
 * @Date 2023/11/13 21:57
 * @Description 权限相关的接口
 */
export interface ILoginResponseBody {
  token: string
}

export interface ILoginRequestParam {
  username: string;
  password: string
}

export interface IUserInfo {
  userId: string;
  userName: string;
  nickName?: string;
  signature?: string
  avatar?: string;
  email?: string;
  idCard?: string;
  phoneNumber?: string
  sex?: number | string;
  status: number | string;
  userType: string | number;
  loginDate?: string | Date;
  loginIp?: string;
}

export interface IMenu {
  menuId: string;
  label: string;
  component?: string;
  icon?: string;
  isCache: string | '0';
  isFrame: string | '1';
  menuType: string;
  orderNum?: number;
  parentId?: string;
  path?: string;
  perms?: string;
  status?: string;
  visible?: string;
  children?: Array<IMenu>
}


export const loginAPI = (data: ILoginRequestParam) => sendPost<ILoginResponseBody, ILoginRequestParam>('/admin/login', data)

export const logoutAPI = () => sendGet('/admin/logout')

export const userInfoAPI = () => sendGet<IUserInfo>('/admin/user/info')

export const userMenusAPI = () => sendGet<Array<IMenu>>('/admin/menu')
